home *** CD-ROM | disk | FTP | other *** search
/ Inside Mac Games Volume 5 #8 / IMG 51 Vol 5-8.iso / Goodies / More For Your Games / Civ II / How to Create Custom Graphics / Ansel beta distribution / Scripts / Animation next >
Text File  |  1994-12-19  |  3KB  |  139 lines

  1. {This file contains additional macros that work with stacks.}
  2.  
  3.  
  4. procedure CheckForStack;
  5. begin
  6.   if nPics=0 then begin
  7.     PutMessage('This macro requires a stack.');
  8.     exit;
  9.   end;
  10.   if nSlices=0 then begin
  11.     PutMessage('This window is not a stack.');
  12.     exit;
  13.   end;
  14. end;
  15.  
  16.  
  17. macro 'Add Slice [A]';    begin CheckForStack; AddSlice end;
  18. macro 'Delete Slice [D]'; begin CheckForStack; DeleteSlice end;
  19. macro 'First Slice [F]';  begin CheckForStack; SelectSlice(1) end;
  20. macro 'Last Slice [L]';   begin CheckForStack; SelectSlice(nSlices) end;
  21.  
  22. macro '(-' begin end;
  23.  
  24.  
  25. macro 'Smooth';
  26. var
  27.   i:integer;
  28. begin
  29.   CheckForStack;
  30.   for i:= 1 to nSlices do begin
  31.     SelectSlice(i);
  32.     SetOption; Smooth;
  33.   end;
  34. end;
  35.  
  36. macro 'Invert';
  37. var
  38.   i:integer;
  39. begin
  40.   CheckForStack;
  41.   for i:= 1 to nSlices do begin
  42.     SelectSlice(i);
  43.     Invert;
  44.   end;
  45. end;
  46.  
  47. macro 'Make Surface Plot Movie…';
  48. var
  49.   i,OldStack,NewStack:integer;
  50.   N,PlotWidth,PlotHeight:integer;
  51.   ScaleFactor:real;
  52.   OneToOne:boolean;
  53. begin
  54.   RequiresVersion(1.50); 
  55.   CheckForStack;
  56.   SaveState;
  57.   OldStack:=PicNumber;
  58.   N:=nSlices;
  59.   PlotWidth:=GetNumber('Surface Plot Width:',300);
  60.   PlotHeight:=GetNumber('Surface Plot Height:',PlotWidth);
  61.   SetNewSize(PlotWidth,PlotHeight);
  62.   MakeNewStack('Stack');
  63.   NewStack:=PicNumber;
  64.   SelectPic(OldStack);
  65.   for i:= 1 to N do begin
  66.     SelectSlice(1);
  67.     SurfacePlot;
  68.     SelectAll;
  69.     Copy;
  70.     Dispose;
  71.     SelectPic(NewStack);
  72.     if i<>1 then AddSlice;
  73.     Paste;
  74.     SelectPic(OldStack);
  75.     DeleteSlice;
  76.   end;
  77.   Dispose; {OldStack}
  78.   RestoreState;
  79. end;
  80.  
  81. macro 'Make Expression Movie… [E]';
  82. {
  83. Requires the Expression 3.0b filter plug-in, which
  84. is available by anonymous FTP from zippy.nimh.nih.gov,
  85. in the /pub/nih-image/plug-ins directory.
  86. }
  87. var
  88.   width,height,nframes,i:integer;
  89. begin
  90.   RequiresVersion(1.56);
  91.   width:=GetNumber('Width:',200);
  92.   height:=GetNumber('Height:',width);
  93.   nframes:=GetNumber('Number of Frames:',50);
  94.   SetNewSize(width,height);
  95.   MakeNewStack('Stack');
  96.   MakeNewWindow('Temp');
  97.   CallFilter('Reset');
  98.   for i:=1 to nframes do begin
  99.     SelectWindow('Temp');
  100.     CallFilter('Expression 3.0');
  101.     SelectAll;
  102.     Copy;
  103.     SelectWindow('Stack');
  104.     if i<>1 then AddSlice;
  105.     paste;
  106.   end;
  107.   SelectWindow('Temp');
  108.   Dispose;
  109. end;
  110.  
  111. macro 'Animate Stack';
  112. var
  113.   i,delay:integer;
  114. begin
  115.   RequiresVersion(1.56);
  116.   CheckForStack;
  117.   i:=0;
  118.   delay:=0.1;
  119.   repeat
  120.     i:=i+1;
  121.     if i>nSlices then i:=1;
  122.     Wait(delay);
  123.     SelectSlice(i);
  124.     if KeyDown('shift') then delay:=1.5*delay;
  125.     if delay>1 then delay:=1;
  126.     if KeyDown('control') then delay:=0.66*delay;
  127.     if KeyDown('option') then beep;
  128.     ShowMessage('delay=',delay:4:2);
  129.   until button;
  130. end;
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.